package com.example;

import com.example.mapper.DemoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Classname Service2Impl
 * @Description TODO
 * @Date 2021/4/28 21:50
 * @Created by yin
 */
@Service
@Transactional
public class Service2Impl implements Service2 {
    @Autowired
    Service1 service1;
    @Autowired
    DemoMapper demoMapper;


    @Override
    public void transaction1T() {
        demoMapper.add("yin",100);
        try {
            service1.transaction1();
        } catch (Exception e) {
            e.printStackTrace();
        }
        demoMapper.minus("yin",100);
    }

    @Override
    public void transaction2T() {
        demoMapper.add("yin",100);
        try {
            service1.transaction2();
        } catch (Exception e) {
            e.printStackTrace();
        }
        demoMapper.minus("yin",100);
    }

    @Override
    public void transaction3T() {
        demoMapper.add("yin",100);
        try {
            service1.transaction2();
        } catch (Exception e) {
            e.printStackTrace();
        }
        demoMapper.minus("yin",100);
    }
}
